<template>
    <div class="add-equipment">
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>单位名称</label>
            </div>
            <div>
                <p>{{formData.ParentName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>项目名称</label>
            </div>
            <div>
                <p>{{formData.ProjectName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>设备类型</label>
            </div>
            <div>
                <p>{{formData.EquipmentTypeName}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>自编号</label>
            </div>
            <div>
                <p>{{formData.EquipmentNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>设备型号</label>
            </div>
            <div>
                <p>{{formData.EquipmentModeNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>备案编号</label>
            </div>
            <div>
                <p>{{formData.EquipmentRecordNo}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>是否自有设备</label>
            </div>
            <div>
                <p>{{formData.IsSelfEquipment}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>安装日期</label>
            </div>
            <div>
                <p>{{formData.SetupDate?formData.SetupDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>进场日期</label>
            </div>
            <div>
                <p>{{formData.EntryDate?formData.EntryDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>验收日期</label>
            </div>
            <div>
                <p>{{formData.CheckDate?formData.CheckDate.split(' ')[0]:''}}</p>
            </div>
        </div>
        <div class="form-item form-item-style1">
            <div class="label-title">
                <label>安装单位</label>
            </div>
            <div>
                <p>{{formData.SetupUint}}</p>
            </div>
        </div>
        <div class="form-item form-item-style2">
            <div class="label-title">
                <label>参加验收人员</label>
            </div>
            <div>
                <p class="textarea">{{formData.CheckPerson}}</p>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3 data-v-d3024438="">验收要求</h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in formData.Items"
                 :key="index">
                <div class="label-title label-title1">
                    <label>{{item.CheckPoint}}</label>
                </div>
                <div class="select-section">
                    <div :class='{"active":item.CheckResult == "符合要求"}'>
                        符合
                    </div>
                    <div :class='{"active":item.CheckResult != "符合要求"}'>
                        不符合
                    </div>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                附件信息
            </h3>
            <div class="form-item form-item-style1"
                 v-for="(item,index) in formData.AttchFile"
                 :key="index"
                 @click="preview(item.FilePath)">
                <div class="label-title label-title1">
                    <label>附件</label>
                </div>
                <div class="right-section">
                    <span>预览</span>
                    <x-icon type="ios-arrow-right"
                            size="20"
                            class="icon-right"></x-icon>
                </div>
            </div>
        </div>
        <div class="cut-off-rule"></div>
        <div class="form-section">
            <h3>
                验收结果
            </h3>
            <div class="form-item form-item-style1">
                <div class="label-title">
                    <label>验收结论</label>
                </div>
                <div class="select-section">
                    <div :class="{'active':formData.CheckResult == '合格'}">
                        合格
                    </div>
                    <div :class="{'active':formData.CheckResult != '合格'}">
                        不合格
                    </div>
                </div>
            </div>
            <div class="form-item form-item-style2">
                <div class="label-title">
                    <label>验收意见</label>
                </div>
                <div>
                    <p class="textarea">{{formData.CheckRemark}}</p>
                </div>
            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>
<script>
import upload from '@/commonComponents/upload/index'
import myMenu from '@/commonComponents/menu'
export default {
    name: 'addEquipment',
    data () {
        return {
            startTime: '',
            endTime: '',
            userInfo: '',
            formData: {
                ID: '',
                EntryDate: '', // 进场时间
                CheckDate: '', // 验收时间
                IsResults: '1', // 验收结果1：合格 0不合格
                AcceptanceContent: '', // 验收内容（设备类型选择其他时）
                AcceptanceConclusion: '', // 验收意见
                CheckPerSonnel: '', // 验收人员
                EquipmentTypeNo: '' // 设备类型编号
            },
            regImg: /\.(png|jpg|PNG|JPG|jpeg|JPEG|gif|GIF)$/
        }
    },
    components: {
        upload,
        myMenu
    },
    created () {
        this.$vux.loading.show({
            text: '加载中...'
        })
        this.userInfo = JSON.parse(localStorage.getItem('userInfo')) || {}
        this.formData.ID = this.$route.query.id
        this.getSetupCheckDetail()
    },
    methods: {
        preview (filePath) {
            if (this.regImg.test(filePath)) {
                this.$router.push({
                    path: '/previewImg',
                    query: {
                        previewImg: filePath
                    }
                })
            } else {
                wx.miniProgram.navigateTo({
                    url: `/pages/openDocument/index?filePath=${filePath}`
                })
            }
        },
        getSetupCheckDetail () {
            let params = {
                'allowPaging': false,
                'business': 'getSetupCheckDetail',
                'data': {
                    ID: this.formData.ID
                },
                'pageIndex': 0,
                'pageSize': 20,
                'tokenId': '',
                'userId': this.userInfo.userid
            }
            this.$axiosAjax.getConfigJson(params).then((res) => {
                if (res.data.code === 0) {
                    this.formData = res.data.data
                    this.$forceUpdate()
                }
            }).catch(() => {

            }).finally(() => {
                this.$vux.loading.hide()
            })
        }
    }
}
</script>
<style lang="less" scoped>
.select-section {
    display: flex;
}
.select-section div {
    padding-left: 26px;
    background: url(../../../../static/images/select.png) no-repeat left center;
    background-size: 17px 17px;
}
.select-section div:first-child {
    margin-right: 58px;
}
.select-section .active {
    background: url(../../../../static/images/selected.png) no-repeat left
        center;
    background-size: 17px 17px;
}
.add-equipment .label-title1 {
    width: 168px;
    line-height: 18px;
}
.select-section div:first-child {
    margin-right: 28px;
}
</style>
